package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.manage.domain.EventSurgery;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.SurgeryWorker;
import com.ruoyi.manage.service.ISurgeryWorkerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 手术参与人员Controller
 * 
 * @author liuyangyang
 * @date 2025-06-08
 */
@RestController
@RequestMapping("/manage/surgeryworker")
public class SurgeryWorkerController extends BaseController
{
    @Autowired
    private ISurgeryWorkerService surgeryWorkerService;

    /**
     * 查询手术参与人员列表
     */
    @PreAuthorize("@ss.hasPermi('manage:surgeryworker:list')")
    @GetMapping("/list")
    public TableDataInfo list(SurgeryWorker surgeryWorker)
    {
        startPage();
        List<SurgeryWorker> list = surgeryWorkerService.selectSurgeryWorkerList(surgeryWorker);
        return getDataTable(list);
    }

    /**
     * 导出手术参与人员列表
     */
    @PreAuthorize("@ss.hasPermi('manage:surgeryworker:export')")
    @Log(title = "手术参与人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SurgeryWorker surgeryWorker)
    {
        List<SurgeryWorker> list = surgeryWorkerService.selectSurgeryWorkerList(surgeryWorker);
        ExcelUtil<SurgeryWorker> util = new ExcelUtil<SurgeryWorker>(SurgeryWorker.class);
        util.exportExcel(response, list, "手术参与人员数据");
    }

    /**
     * 获取手术参与人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:surgeryworker:query')")
    @GetMapping(value = "/{surgeryWorkerId}")
    public AjaxResult getInfo(@PathVariable("surgeryWorkerId") Long surgeryWorkerId)
    {
        return success(surgeryWorkerService.selectSurgeryWorkerBySurgeryWorkerId(surgeryWorkerId));
    }

    /**
     * 新增手术参与人员
     */
    @PreAuthorize("@ss.hasPermi('manage:surgeryworker:add')")
    @Log(title = "手术参与人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<SurgeryWorker> surgeryWorkers)
    {
        surgeryWorkerService.insertSurgeryWorker(surgeryWorkers);

        return AjaxResult.success("操作成功");

    }

    /**
     * 修改手术参与人员
     */
    @PreAuthorize("@ss.hasPermi('manage:surgeryworker:edit')")
    @Log(title = "手术参与人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SurgeryWorker surgeryWorker)
    {
        return toAjax(surgeryWorkerService.updateSurgeryWorker(surgeryWorker));
    }

    /**
     * 删除手术参与人员
     */
    @PreAuthorize("@ss.hasPermi('manage:surgeryworker:remove')")
    @Log(title = "手术参与人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{surgeryWorkerIds}")
    public AjaxResult remove(@PathVariable Long[] surgeryWorkerIds)
    {
        return toAjax(surgeryWorkerService.deleteSurgeryWorkerBySurgeryWorkerIds(surgeryWorkerIds));
    }
}
